// LemCoop
// Copyright (C) 2013  Oliver Naumann <bldrax@gmail.com>

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef LEMC_LOGMANAGER_H
#define LEMC_LOGMANAGER_H

#include <ctime>
#include <string>
#include <fstream>

class LogManager
{
private:
	// The outstream.
	static std::ofstream m_out;

	/*
	* Creates a timestamp containing the date and time, separated by the given characters/strings.
	*
	* @param date_separator The characters to separate year, month and day.
	* @param date_time_separator The characters that separate the date from the time.
	* @param time_separator The characters that separate hours, minutes and seconds.
	*
	* @return A string containing the constructed timestamp.
	*/
	static std::string CreateTimestamp(std::string date_separator, std::string date_time_separator, std::string time_separator);

public:
	/*
	* Creates a new logfile and opens the outstream.
	*
	* @param file_prefix The prefix of the logfile (e.g. the path where the logfile should be stored or a prefix for the filename).
	* Appended will be a timestamp and the file ending '.log'.
	*/
	static void Initialize(std::string file_prefix = "");

	/*
	* Writes a message into the logfile.
	* 
	* @param message The message to be stored. A timestamp will be used as a prefix to the message.
	*/
	static void LogLine(std::string message);

	/*
	* Closes the logfile.
	*/
	static void Close();
};

#endif